package com.ruoyi.APPMS.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.APPMS.domain.Salevehicleorder;
import com.ruoyi.APPMS.service.ISalevehicleorderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆销售订单Controller
 *
 * @author 吴春梅
 * @date 2023-07-04
 */
@Api(tags="车辆销售订单控制器类")
@RestController
@RequestMapping("/salevehicleorder/salevehicleorder")
public class SalevehicleorderController extends BaseController
{
    @Autowired
    private ISalevehicleorderService salevehicleorderService;

    /**
     * 查询车辆销售订单列表
     */
    @ApiOperation("询车辆销售订单列表")
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(Salevehicleorder salevehicleorder)
    {
        startPage();
        List<Salevehicleorder> list = salevehicleorderService.list(salevehicleorder);
        return getDataTable(list);
    }

    /**
     * 导出车辆销售订单列表
     */
    @ApiOperation("导出车辆销售订单列表")
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:export')")
    @Log(title = "车辆销售订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Salevehicleorder salevehicleorder)
    {
        List<Salevehicleorder> list = salevehicleorderService.list(salevehicleorder);
        ExcelUtil<Salevehicleorder> util = new ExcelUtil<Salevehicleorder>(Salevehicleorder.class);
        util.exportExcel(response, list, "车辆销售订单数据");
    }

    /**
     * 获取车辆销售订单详细信息
     */
    @ApiOperation("获取车辆销售订单详细信息")
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:query')")
    @GetMapping(value = "/{salevehicleorderid}")
    public AjaxResult getInfo(@PathVariable("salevehicleorderid") Long salevehicleorderid)
    {
        return success(salevehicleorderService.getByid(salevehicleorderid));
    }

    /**
     * 新增车辆销售订单
     */
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:add')")
    @Log(title = "车辆销售订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Salevehicleorder salevehicleorder)
    {
        return toAjax(salevehicleorderService.save(salevehicleorder));
    }

    /**
     * 发货车辆销售订单
     */
    @ApiOperation("车辆销售订单发货")
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:edit')")
    @Log(title = "车辆销售订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Salevehicleorder salevehicleorder)
    {

        salevehicleorderService.createsalevehicleorder2(salevehicleorder);
        salevehicleorderService.createsalevehicleorder3(salevehicleorder);
        return toAjax(salevehicleorderService.createsalevehicleorder(salevehicleorder));
    }

    /**
     * 删除车辆销售订单
     */
    @PreAuthorize("@ss.hasPermi('salevehicleorder:salevehicleorder:remove')")
    @Log(title = "车辆销售订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{salevehicleorderids}")
    public AjaxResult remove(@PathVariable List<Long> salevehicleorderids)
    {
        return toAjax(salevehicleorderService.removeByIds(salevehicleorderids));
    }
}
